-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: optimize argocd-application-controller redis usage #5345
Conversation
… calls Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
@@ -303,7 +303,8 @@ export class PodView extends React.Component<PodViewProps> { | |||
renderMenu: () => this.props.nodeMenu(rnode) | |||
}; | |||
} | |||
|
|||
}); | |||
(tree.nodes || []).forEach((rnode: ResourceTreeNode) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bug fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes. It appears that UI might break if pod appears before the parent resource in ApplicationTree.Nodes
list. After introducing node sorting in backend this reproduces consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few questions, please see below.
And can you please provide comments for the public methods introduced in this change?
util/cache/inmemory.go
Outdated
err := gob.NewEncoder(&buf).Encode(obj) | ||
if err != nil { | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be that we'll silently drop some real errors here? In which cases does gob.NewEncoder()
fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, changed method so it returns an error instead of silently dropping it
util/cache/inmemory.go
Outdated
if !found { | ||
return false | ||
} | ||
existingBuf := bufIf.(bytes.Buffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should safeguard this typecast, but I'm not sure. Can there be something else than bytes.Buffer
in the in-memory cache for whatever reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to panic here, because if In-memory cache has garbage we should restart pod. Added explicit check and panic with the meaningful message
util/cache/twolevelclient.go
Outdated
|
||
type twoLevelClient struct { | ||
inMemoryCache *InMemoryCache | ||
client CacheClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to have some consistency in the member names, i.e. inMemoryCache
and externalCache
. But this is just nitpicking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Renamed
Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
327ce7d
to
d12fe5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for awesome commentary!
LGTM.
Cherry picking to 1.8 since it is fixing unexpected traffic increase caused by #4965 |
* refactor: controller uses two level caching to reduce number of redis calls Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
…j#5345) * refactor: controller uses two level caching to reduce number of redis calls Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Signed-off-by: Alexander Matyushentsev AMatyushentsev@gmail.com
The
argocd-application-controller
uses Redis a LOT that results in significant traffic that might be costly in the cloud. PR introduces two-level caching: before reading/writing to redis controller check in-memory cache first and don't use redis if in-memory cache already has required entry. This is safe since the controller is the only writer to the Redis.